<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>判断一个数是否是素数</title>
</head>
<body>
    <script>
        
        var n = prompt('请输入一个大于1的整数');
        function isZhiShu(n){
            var ZhiShu = true;
            if(n <= 1){
                alert('输入错误');
            }else{
                for(var i = 2; i < n; i++){
                    if(n % i ==0){
                        ZhiShu = false;
                        break;
                    }
                }
                if(ZhiShu){
                    return n + '是素数!'; 
                }else{
                return n + '不是素数!';
                }
            }
        }
        alert(isZhiShu(n));
    </script>
</body>
</html>